package com.xzy.sms.web.domain.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Where;

import com.xzyframework.persistence.BaseEntity;


/**
 * @desc 短信模板
 * @author wjw
 * @time 2017年11月16日下午3:32:01
 */
@Entity
@Table(name = "pub_template")
public class Template extends BaseEntity {
    
    /** 序列化 */
    private static final long serialVersionUID = -936203994181527906L;
    
    /** 主键id，也是applicationId */
    @Id
    @GeneratedValue(generator = "UIDGenerator")
    @GenericGenerator(name = "UIDGenerator", strategy = "com.xzyframework.persistence.UIDGenerator")
    @Column(length = 40)
    private String templateId;
    
    /** 模板名 */
    @NotNull(message = "模板code不能为空")
    @NotBlank(message = "模板code不能为空")
    @Column(length = 40)
    private String code;
    
    /** 模板名 */
    @NotNull(message = "模板名不能为空")
    @NotBlank(message = "模板名不能为空")
    @Column(length = 40)
    private String name;
    
    /** 模板内容 */
    @Column(length = 100)
    private String content;
    
    /** 所属用户 */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", updatable = false, nullable = true)
    @Where(clause = "del_flag='" + DEL_FLAG_NORMAL + "'")
    @NotNull
    private User user;
    
    /**
     * 构造函数
     */
    public Template() {
    }
    
    /**
     * @return the templateId
     */
    public String getTemplateId() {
        return templateId;
    }
    
    /**
     * @param templateId the templateId to set
     */
    public void setTemplateId(String templateId) {
        this.templateId = templateId;
    }
    
    /**
     * @return the name
     */
    public String getName() {
        return name;
    }
    
    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }
    
    /**
     * @return the content
     */
    public String getContent() {
        return content;
    }
    
    /**
     * @param content the content to set
     */
    public void setContent(String content) {
        this.content = content;
    }
    
    /**
     * @return the user
     */
    public User getUser() {
        return user;
    }
    
    /**
     * @param user the user to set
     */
    public void setUser(User user) {
        this.user = user;
    }
    
    /**
     * @return the code
     */
    public String getCode() {
        return code;
    }
    
    /**
     * @param code the code to set
     */
    public void setCode(String code) {
        this.code = code;
    }
    
}
